package com.chat.chat.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chat.chat.entity.Zhandian;
import com.chat.chat.service.ZhandianService;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("zhandian")
public class ZhandianController {
   @Autowired
   ZhandianService zhandianService;

    @GetMapping("zhandian")
   public List<Zhandian> zhandianList(){
       return zhandianService.list();
   }

    @GetMapping("zhandianPage")
    public Page<Zhandian> zhandianPage(Integer page,Integer num){
        Page<Zhandian> zhandianPage = zhandianService.page(new Page<>(page, num));
        if (!zhandianPage.getRecords().isEmpty()){
            zhandianPage.setRecords(zhandianPage.getRecords().subList(0,4));
        }
        return zhandianPage;
    }
}
